#pragma once

namespace ywx {
	template<class Iterator, class Ref, class Ptr>
	class ReverseIterator {
	public:
		typedef ReverseIterator<Iterator, Ref, Ptr> reverse_iterator;

		ReverseIterator(const Iterator& it)
			:_it(it)
		{}

		Ref operator*()
		{
			Iterator tmp = _it;
			return *(--tmp);
		}

		Ptr operator->()
		{
			return &(operator*());
		}

		reverse_iterator operator--()
		{
			return reverse_iterator(++_it);
		}

		reverse_iterator operator++()
		{
			return reverse_iterator(--_it);
		}

		bool operator!=(const reverse_iterator& it)
		{
			return _it != it._it;
		}

		bool operator==(const reverse_iterator& it)
		{
			return _it == it._it;
		}

	private:
		Iterator _it;
	};
}